package com.servlet;
import com.dao.GoodsDAO;
import com.model.Goods;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/mohu")
public class SousuGoodsServlet extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("utf-8");
        request.setCharacterEncoding("utf-8");

        GoodsDAO goodsDao = new GoodsDAO();
        String sousuo = request.getParameter("sousuo");
        System.out.println(sousuo);
        List<Goods> goodsList = goodsDao.mohuchaxun(sousuo);
        System.out.println(goodsList);
        HttpSession session = request.getSession();
        session.setAttribute("goodsList",goodsList);
        response.sendRedirect("sousu.jsp");
    }
}
